package com.example.bbs.web.servlet; /**
 * @auther: zhangxin
 * @Description:
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "LogoutServlet", value = "/bbs/logout")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("UTF-8");
        HttpSession session = req.getSession();
        session.removeAttribute("loginUser");
        Cookie cookie = new Cookie("loginUser", null);
        cookie.setMaxAge(0);
        resp.addCookie(cookie);
        resp.sendRedirect("/login.jsp");
    }

}
